package com.example.pt.config;

import com.example.pt.service.PromotionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

@Configuration
@EnableScheduling
public class PromotionTask {
    @Autowired
    private PromotionService promotionService;

    // 每周日凌晨2点执行免费促销
    //@Scheduled(cron = "0 0 2 * * SUN")
    @Scheduled(cron = "0 53 22 * * *")
    public void weeklyFreePromotionTask() {
        promotionService.applyWeeklyFreePromotion();
    }

    // 每天凌晨2点执行新种子折扣促销
    //@Scheduled(cron = "0 0 2 * * *")
    @Scheduled(cron = "0 53 22 * * *")
    public void newTorrentPromotionTask() {
        promotionService.applyNewTorrentPromotion();
    }
}